package com.fivestar.finance.app.ui.splash;


import com.fivestar.finance.app.api.CommonApi;
import com.fivestar.finance.app.bean.HttpResponse;
import com.fivestar.finance.app.core.ExSubscriber;
import com.fivestar.finance.app.core.FFException;
import com.fivestar.finance.app.core.mvp.BasePresenter;
import com.fivestar.finance.app.injector.scope.ActivityScope;

import java.util.concurrent.TimeUnit;

import javax.inject.Inject;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by sll on 2016/5/31.
 */
@ActivityScope
public class SplashPresenter extends BasePresenter<ISplashView> {

    private CommonApi commonApi;

    @Inject
    public SplashPresenter(CommonApi commonApi) {
        this.commonApi = commonApi;
    }

    // 版本更新
    public void checkUpdate(String curVersion) {

        ExSubscriber exSubscriber = new ExSubscriber<HttpResponse<String>>(this, false) {

            @Override
            protected void onSuccess(Object object) {

            }

            @Override
            protected void onFailure(FFException e) {

            }
        };
        this.mCompositeSubscription.add(
                commonApi.getUpdateInfo(curVersion).take(5, TimeUnit.SECONDS)
                        .subscribeOn(Schedulers.io()).
                        observeOn(AndroidSchedulers.mainThread()).subscribe(exSubscriber));
    }


}
